# -*- coding: utf-8 -*-
# 操作内容：
# @Software: PyCharm
# @File: createtrade_api.py
# @Author: 一碗好酒（张智）
# @E-mail: 1473658931@qq.com, 
# @Time: 7月 08, 2021
# ---
import jsonpath

from api.base_api import BuyerBaseApi
from api.buyer.Buynow_api import BuyNowApi
from api.buyer.login_api import BuyerLoginApi
from common.client import RequestsClient


class CreateTradeApi(BuyerBaseApi):
    def __init__(self):
        super().__init__()
        # self.host = 'http://www.mtxshop.com:7002'
        self.url = self.host + '/trade/create'
        self.params = {
            'client': 'PC',
            'way': 'BUY_NOW'
        }
        self.method = 'post'
        # self.headers = {
        #     'Authorization': RequestsClient.access_token  #公共引用token写在基类中。
        # }
if __name__ == '__main__':
    buyerapi = BuyerLoginApi()
    resp = buyerapi.send()
    RequestsClient.access_token = jsonpath.jsonpath(resp.json(),'$.access_token')[0]  #jsonpath要练习

    resp = BuyNowApi().send()

    resp = CreateTradeApi().send()
    print(resp.status_code)
    print(resp.text)
